package com.jcf.springboot.controller.sys;

import com.jcf.springboot.common.R;
import com.jcf.springboot.security.util.JwtUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ${chaofan.ji}
 * @since 2025/5/22
 */
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("")
public class RefreshTokenController {

  @Autowired
  private JwtUtil jwtUtil;

  @GetMapping("refreshToken")
  public R refreshToken(String userName) {
//刷新token
    String newToken = jwtUtil.generateToken(userName);
    log.info("刷新token  "+ newToken);
    Map map = new HashMap<>();
     map.put("authorization",newToken);
    return R.ok().data(map);
  }

}
